<template>
    <div class="bgg">
      <div class="tPart">
        <div class="leftP">
          <!--左边部分-->
          <div class="parts">
            <!--左上00-->
            <Row class="btnnn">
              <Col span="12">
              <RadioGroup v-model="models.modelPress" type="button" size="small" @on-change="pressRadioChange">
                <Radio label="1">自动提示</Radio>
                <Radio label="0">人工控制</Radio>
              </RadioGroup>
                <Button size="small" type="default"  @click="setCustomParam(0)">
                  设定压力
                </Button>
              </Col>
              <Col span="12" class="showNum">
                <H3 class="ddkkkk">供气总管压力: &nbsp;&nbsp; {{totalShow.press}} &nbsp;&nbsp; Mpa</H3>
                <!--<H3 class="ddkkk">阀值:  {{warnData.setLimitDown}} &nbsp; ——&nbsp; {{warnData.setLimitUp}}</H3>-->
              </Col>
            </Row>
            <KongYa v-for="(item, index) in devices['空压机']" :key="index" :data="item" :model="models.modelPress"
                    @dblclick.native="models.modelPress === '0' ? showProcess(item) : ''" :press-range="warnData"
                    :total-press="totalShow.press"
            ></KongYa>
            <Spin fix v-if="pressSendStatus">
              <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
              <div>{{tipName3}}</div>
            </Spin>
          </div>
          <div class="gass"></div>
          <div class="parts">
            <!--左下-->
            <Row class="btnnn">
             <!--<Col span="12">-->
              <!--</Col>-->
              <Col span="12">
                <RadioGroup v-model="models.modelCool" type="button" size="small" @on-change="pressRadioChange2">
                  <Radio label="1">自动控制</Radio>
                  <Radio label="0">人工控制</Radio>
                </RadioGroup>
                <Button size="small" type="default"  @click="setCustomParam(4)">
                  设定流量
                </Button>
              </Col>
              <Col span="12" class="showNum">
                <H3 style="float:right;margin-left: 30px">供气总管流量: &nbsp;&nbsp; {{totalShow.flow}} &nbsp;&nbsp; m³/min</H3>
                <H3>供气总管露点: &nbsp;&nbsp; {{totalShow.ludian}} &nbsp;&nbsp;Ctd</H3>
              </Col>
            </Row>
            <LengGanCard v-for="(item, index) in devices['冷干机']" :key="index" :data="item"
                    :model="models.modelPress"
                    @dblclick.native="models.modelPress === '0' ? showProcess(item) : ''"></LengGanCard>
            <Spin fix v-if="press2SendStatus">
              <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
              <div>{{tipName4}}</div>
            </Spin>
          </div>
        </div>
        <div class="leftR">
          <!--右边部分-->
          <div class="parts">
            <!--右上-->
            <Row class="btnnn">
              <Col span="12">
              <RadioGroup v-model="models.modelBeng" type="button" size="small" @on-change="radioChangeBeng">
                <Radio label="1">自动控制</Radio>
                <Radio label="0">人工控制</Radio>
              </RadioGroup>
                <Button size="small" type="default"  @click="setCustomParam(1)">
                  设定压力
                </Button>
              </Col>
              <Col span="12" class="showNum">
                <H3>冷却供水压力: &nbsp;&nbsp;{{totalShow.bengPress}} &nbsp;&nbsp;Mpa</H3>
              </Col>
            </Row>
            <CoolBengCard v-for="(item, index) in devices['冷却泵']" :key="index" :data="item"
                    :model="models.modelBeng"
                          @dblclick.native="models.modelBeng === '0' ? showProcess(item) : ''"></CoolBengCard>
            <Spin fix v-if="bengModelSendStatus">
              <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
              <div>{{tipName}}</div>
            </Spin>
          </div>
          <div class="gass"></div>
          <div class="parts">
            <!--右下-->
            <Row class="btnnn">
              <Col span="12">
              <RadioGroup v-model="models.modelTower" type="button" size="small" @on-change="radioChangeTower">
                <Radio label="1">自动控制</Radio>
                <Radio label="0">人工控制</Radio>
              </RadioGroup>
                <Button size="small" type="default"  @click="setCustomParam(2)">
                  设定温度</Button>
              </Col>
              <Col span="12" class="showNum">
                 <H3>冷却回水温度: &nbsp;&nbsp; {{totalShow.towerTemp}} &nbsp;&nbsp;℃</H3>
              </Col>
            </Row>
            <CoolTowerCard ref="CoolTowerCard" v-for="(item, index) in devices['冷却塔']" :key="index" :data="item"
                          :model="models.modelTower"
                           @dblclick.native="models.modelTower === '0' ? showProcess(item) : ''"></CoolTowerCard>
            <Spin fix v-if="towerModelSendStatus">
              <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
              <div>{{tipName2}}</div>
            </Spin>
          </div>
        </div>
      </div>
      <div class="fgap"></div>
      <div class="bPart">
        <div class="leftBP">
          <RunChain ref="chain"></RunChain>
        </div>
        <div class="rightBP">
          <div class="bbleft">
            <H2>{{operation1}}</H2>
            <H2>{{operation2}}</H2>
          </div>
          <div class="bbright">
            <!--空压机组配置-->
            <div style="width: 100%;height: 100%;" v-show="kitty == 0">
              <CellGroup>
                <Cell title="压力上限">
                  <InputNumber size="small" :max="500" :min="0" slot="extra"
                               v-model="setKongYaParam.setUp"></InputNumber>
                </Cell>
                <Cell title="压力下限">
                  <InputNumber size="small" :max="500" :min="0" slot="extra"
                               v-model="setKongYaParam.setDown"></InputNumber>
                </Cell>
              </CellGroup>
              <Row style="text-align: right;margin-right: 15px;">
                <Button type="primary" size="small" style="width: 80px;" @click="sendSetKonYaPress()"
                        :loading="setKongYaParam.sendingStatus"> 发送
                </Button>
              </Row>
            </div>
            <!--冷却泵组配置-->
            <div style="width: 100%;height: 100%;" v-show="kitty == 1">
            <CellGroup>
              <Cell title="压力上限">
                <InputNumber size="small" :max="500" :min="0" slot="extra" v-model="setPressParam.setUp"></InputNumber>
              </Cell>
              <Cell title="压力下限">
                <InputNumber size="small" :max="500" :min="0" slot="extra" v-model="setPressParam.setDown"></InputNumber>
              </Cell>
            </CellGroup>
            <Row style="text-align: right;margin-right: 15px;">
              <Button type="primary" size="small" style="width: 80px;" @click="sendSetPress()"
                      :loading="setPressParam.sendingStatus"> 发送
              </Button>
            </Row>
            </div>
            <!--冷却塔组配置-->
            <div style="width: 100%;height: 100%;" v-show="kitty == 2">
              <CellGroup>
                <Cell title="温度上限">
                  <InputNumber size="small" :max="500" :min="0" slot="extra"
                               v-model="setTemeputureParam.setUp"></InputNumber>
                </Cell>
                <Cell title="温度下限">
                  <InputNumber size="small" :max="500" :min="0" slot="extra"
                               v-model="setTemeputureParam.setDown"></InputNumber>
                </Cell>
              </CellGroup>
              <Row style="text-align: right;margin-right: 15px;">
                <Button type="primary" size="small" style="width: 80px;" @click="sendSetTempeture()"
                        :loading="setTemeputureParam.sendingStatus"> 发送
                </Button>
              </Row>
            </div>
            <!--冷却泵 单个 设定  频率-->
            <div style="width: 100%;height: 100%;" v-show="kitty == 3">
              <CellGroup>
                <Cell title="设置频率">
                  <InputNumber size="small" :max="500" :min="0" slot="extra"
                               v-model="dataObj.setFrequ" :disabled="this.drawerData.manual == 1"></InputNumber>
                </Cell>
                <Cell title="">
                </Cell>
              </CellGroup>
              <Row style="text-align: right;margin-right: 15px;">
                <Button type="primary" size="small" style="width: 80px;" @click="sendSetFreq()"
                        :loading="setSingleFreq.sendingStatus" :disabled="this.drawerData.manual == 1"> 发送
                </Button>
              </Row>
            </div>
            <!--冷干机流量范围设置-->
            <div style="width: 100%;height: 100%;" v-show="kitty == 4">
              <CellGroup>
                <Row style="margin: 3px 0px 3px 10px;">
                  <Col span="5">
                    <span style="margin:0px">0&nbsp; ≤ </span>
                    <Input v-model="setColdDryer.setOneFlow" size="small" style="width: 37px;margin-left: 3px"></Input>
                  </Col>
                  <Col span="5">
                    <span style="margin-left:10px"> ≤ </span>
                    <Input v-model="setColdDryer.setTwoFlow" size="small" style="width: 37px;margin-left: 10px"></Input>
                  </Col>
                  <Col span="6">
                    <span style="margin-left:11px"> ≤ </span>
                    <Input v-model="setColdDryer.setThreeFlow" size="small" style="width: 37px;margin-left: 7px"></Input>
                  </Col>
                  <Col span="8">
                    <span style="margin-right: 13px"> ≤ </span>
                    <Input v-model="setColdDryer.setFourFlow" size="small" style="width: 37px;margin-right: 20px"></Input>
                  </Col>
                </Row>
                <Row style="margin: 0px 0px 0px 15px;">
                  <Col span="5">
                    <Input v-model="setColdDryer.setOneBig" size="small" style="width: 22px;"></Input>
                    <span>大</span>
                  </Col>
                  <Col span="5">
                    <Input v-model="setColdDryer.setTwoBig" size="small" style="width: 22px;margin-left: 0px"></Input>
                    <span>大</span>
                  </Col>
                  <Col span="5">
                    <Input v-model="setColdDryer.setThreeBig" size="small" style="width: 22px;margin-left: 0px"></Input>
                    <span>大</span>
                  </Col>
                  <Col span="5">
                    <Input v-model="setColdDryer.setFourBig" size="small" style="width: 22px;margin-left: 4px"></Input>
                    <span>大</span>
                  </Col>
                  <Col span="4">
                    <Input v-model="setColdDryer.setFiveBig" size="small" style="width: 22px;margin-left: 12px"></Input>
                    <span>大</span>
                  </Col>
                </Row>
                <Row style="margin: 3px 0px 3px 15px;">
                  <Col span="5">
                    <Input v-model="setColdDryer.setOneSmall" size="small" style="width: 22px;"></Input>
                    <span>小</span>
                  </Col>
                  <Col span="5">
                    <Input v-model="setColdDryer.setTwoSmall" size="small" style="width: 22px;margin-left: 0px"></Input>
                    <span>小</span>
                  </Col>
                  <Col span="5">
                    <Input v-model="setColdDryer.setThreeSmall" size="small" style="width: 22px;margin-left: 0px"></Input>
                    <span>小</span>
                  </Col>
                  <Col span="5">
                    <Input v-model="setColdDryer.setFourSmall" size="small" style="width: 22px;margin-left: 4px"></Input>
                    <span>小</span>
                  </Col>
                  <Col span="4">
                    <Input v-model="setColdDryer.setFiveSmall" size="small" style="width: 22px;margin-left: 12px"></Input>
                    <span>小</span>
                  </Col>
                </Row>
              </CellGroup>
              <Row style="text-align: right;margin-right: 15px;">
                <Button type="primary" size="small" style="width: 80px;" @click="sendSetColdDryer()"
                        :loading="setColdDryer.sendingStatus" :disabled="this.drawerData.manual == 1"> 发送
                </Button>
              </Row>
            </div>
          </div>
        </div>
      </div>
    </div>
</template>

<script>
  import KongYa from './modules/KongYaCard'
  import LengGanCard from './modules/LengGanCard'
  import CoolBengCard from './modules/CoolBengCard'
  import CoolTowerCard from './modules/CoolTowerCard'
  import RunChain from './modules/RunChain'
  export default {
    name: 'Automation3',
    components: {KongYa, CoolBengCard, CoolTowerCard, RunChain, LengGanCard},
    mounted: function () {
      this.loadModels(160)
      this.loadModels(161)
      this.loadModels(162)
      this.loadModels(163)
      // 加载报警阀值 162
      this.requestForPropsValues(162)
      this.loadDevList()
      this.loadTotalRealData()
      this.timer.push(setInterval(() => {
        this.loadTotalRealData()
      }, 2670))
    },
    beforeDestroy: function () {
      this.timer.forEach(item => window.clearInterval(item))
    },
    data () {
      return {
        dataObj: {
          setFrequ: ''
        },
        alertTitle: '',
        drawerData: {},
        drawerDataChange: {},
        timer: [],
        warnData: {
          setLimitUp: 0,
          setLimitDown: 0
        },
        totalShow: {
          ludian: 0,
          press: 0,
          flow: 0,
          bengPress: 0,
          towerTemp: 0
        },
        pressSendStatus: false,
        press2SendStatus: false,
        bengModelSendStatus: false,
        towerModelSendStatus: false,
        models: {
          modelPress: '1',
          modelCool: '1',
          modelBeng: '1',
          modelTower: '1'
        },
        devices: {
          '空压机': [],
          '冷干机': [],
          '冷却泵': [],
          '冷却塔': []
        },
        tipName: '发送指令中....',
        tipName2: '发送指令中....',
        tipName3: '发送指令中....',
        tipName4: '发送指令中....',
        operation1: '未选择',
        operation2: '设定参数',
        kitty: 999,
        setColdDryer: {
          setOneFlow: 0,
          setTwoFlow: 0,
          setThreeFlow: 0,
          setFourFlow: 0,
          setOneBig: 0,
          setOneSmall: 0,
          setTwoBig: 0,
          setTwoSmall: 0,
          setThreeBig: 0,
          setThreeSmall: 0,
          setFourBig: 0,
          setFourSmall: 0,
          setFiveBig: 0,
          setFiveSmall: 0,
          devId: 163,
          sendingStatus: false
        },
        setKongYaParam: {
          setUp: 0.45,
          setDown: 0.36,
          devId: 162,
          sendingStatus: false
        },
        setPressParam: {
          setUp: 0.45,
          setDown: 0.36,
          devId: 160,
          sendingStatus: false
        },
        setTemeputureParam: {
          setUp: 28,
          setDown: 35,
          devId: 161,
          sendingStatus: false
        },
        setSingleFreq: {
          param: '',
          sendingStatus: false,
          cmd: 'setFrep'
        }
      }
    },
    methods: {
      requestForPropsValues (id) {
        // 加载设备的报警阀值
        let params = {devId: id}
        window.myapi.do_post('iot/dev/def', params).then(resp => {
          if (resp.status === 200 && resp.data.status === 200) {
            let result = resp.data.data
            let upOne = result.find(item => item.name === 'setLimitUp')
            if (upOne) {
              this.warnData['setLimitUp'] = parseFloat(upOne.value)
            }
            let downOne = result.find(item => item.name === 'setLimitDown')
            if (downOne) {
              this.warnData['setLimitDown'] = parseFloat(downOne.value)
            }
          }
        }).catch(error => {
        }).finally(() => {
        })
      },
      loadModels (id) {
        let params = {devId: id, name: 'auto'}
        window.myapi.do_post('iot/dev/def', params).then(resp => {
          if (resp.status === 200 && resp.data.status === 200) {
            let result = resp.data.data
            if (id === 160) {
                this.models.modelBeng = result[0].value + ''
            }
            if (id === 161) {
              this.models.modelTower = result[0].value + ''
            }
            if (id === 162) {
              this.models.modelPress = result[0].value + ''
              // this.models.modelCool = result[0].value + ''
            }
            if (id === 163) {
              // this.models.modelPress = result[0].value + ''
              this.models.modelCool = result[0].value + ''
            }
          }
        }).catch(error => {
        }).finally(() => {
        })
      },
      loadDevList () {
        window.myapi.do_gett('process/list', {page: 0, size: 1000}).then(resp => {
          if (resp.status === 200 && resp.data.status === 200) {
            this.makeDeviceList(resp.data.data.content)
          }
        }).catch(error => {
        }).finally(() => {
        })
      },
      loadTotalRealData () {
        // pCGjkAdw  固定获取 22
        window.myapi.do_post('iot/dev/sysReal', {uuid: 'pCGjkAdw'}).then(resp => {
          if (resp.status === 200 && resp.data.status === 200) {
            this.handleStatus(resp.data.data)
          }
        }).finally(() => {
        })
      },
      handleStatus (exam) {
        let ludianItem = exam.find(item => item.keyName === '露点')
        let pressItem = exam.find(item => item.keyName === '压力')
        let liuLiangItem = exam.find(item => item.keyName === '流量')
        let bengPressItem = exam.find(item => item.keyName === '冷却总管压力')
        let towerTempItem = exam.find(item => item.keyName === '冷却总管温度')
        if (ludianItem) {
          this.totalShow.ludian = ludianItem.value
        }
        if (pressItem) {
          this.totalShow.press = pressItem.value
        }
        if (liuLiangItem) {
          this.totalShow.flow = liuLiangItem.value
        }
        if (bengPressItem) {
          this.totalShow.bengPress = bengPressItem.value
        }
        if (towerTempItem) {
          this.totalShow.towerTemp = towerTempItem.value
        }
      },
      makeDeviceList (data) {
        this.devices['空压机'] = data.filter(item => item.group === 100)
        this.devices['冷干机'] = data.filter(item => item.group === 101)
        this.devices['冷却泵'] = data.filter(item => item.group === 102)
        this.devices['冷却塔'] = data.filter(item => item.group === 103)
      },
      showProcess (bingo) {
        // 发送数据到进程操作栏
        if (bingo.name.indexOf('#冷却泵') > -1){}else{
            this.$refs.chain.feedMe(bingo)
         }
        window.myapi.do_post('iot/dev/sysReal', {uuid: bingo.uuid}).then(resp => {
          if (resp.status === 200 && resp.data.status === 200) {
            this.dataObj = resp.data.data
            let manualFrequency = this.dataObj.find(item => item.keyName === '本地手动')
            if (manualFrequency) {
              this.drawerData.manual = manualFrequency.value
            }
            this.dataObj.setFrequ = ''
            console.log(this.dataObj.setFrequ)
            if (bingo.name.indexOf('#冷却泵') > -1) {
              this.setSingleFreq.devId = bingo.processes[0].devId
              this.operation1 = bingo.name
              this.operation2 = '设定给定频率'
              this.setCustomParam(3)
            } else {
              this.makeSettingDefault()
            }
          }
        }).finally(() => {

        })
      },
      setCustomParam (index) {
        // 获取设定的默认值 冷却泵（index = 0， id = 162）
        if (index === 0) {
          this.requestForDefValues(index, this.setKongYaParam.devId)
        }
        // 获取设定的默认值 冷却泵（index = 1， id = 160）
        if (index === 1) {
          this.requestForDefValues(index, this.setPressParam.devId)
        }
        // 获取设定的默认值 冷却塔（index = 2， id = 161）
        if (index === 2) {
          this.requestForDefValues(index, this.setTemeputureParam.devId)
        }
        if (index === 4) {
          this.requestForDefValues(index, this.setColdDryer.devId)
        }
        // 2 为 恒温冷却塔   1为 恒压冷却泵
        if (index === 0 || index === 1 || index === 2 || index === 4) {
          this.operation1 = (index === 0 ? '空压机组' : (index === 1 ? '冷却泵组' : (index === 2 ? '冷却塔组' : '冷干机组')))
          this.operation2 = (index === 0 ? '设定压力范围' : (index === 1 ? '设定恒压参数' : (index === 2 ? '设定恒温参数' : '设定流量参数')))
        }
        this.kitty = index
      },
      requestForDefValues (index, id) {
        let params = {devId: id}
        window.myapi.do_post('iot/dev/def', params).then(resp => {
          if (resp.status === 200 && resp.data.status === 200) {
            this.handleDefValues(index, resp.data.data)
          }
        }).catch(error => {
        }).finally(() => {
        })
      },
      handleDefValues (index, data) {
          // 空压机
        if (index === 0) {
          let upOne = data.find(item => item.name === 'setUp')
          if (upOne) {
            this.setKongYaParam.setUp = parseFloat(upOne.value)
          }
          let downOne = data.find(item => item.name === 'setDown')
          if (downOne) {
            this.setKongYaParam.setDown = parseFloat(downOne.value)
          }
        }
          // 冷却泵
        if (index === 1) {
          let upOne = data.find(item => item.name === 'setUp')
          if (upOne) {
            this.setPressParam.setUp = parseFloat(upOne.value)
          }
          let downOne = data.find(item => item.name === 'setDown')
          if (downOne) {
            this.setPressParam.setDown = parseFloat(downOne.value)
          }
        }
        // 冷却塔
        if (index === 2) {
          let upOne = data.find(item => item.name === 'setUp')
          if (upOne) {
            this.setTemeputureParam.setUp = parseFloat(upOne.value)
          }
          let downOne = data.find(item => item.name === 'setDown')
          if (downOne) {
            this.setTemeputureParam.setDown = parseFloat(downOne.value)
          }
        }
        if (index === 4) {
          let oneFlow = data.find(item => item.name === 'setOneFlow')
          let twoFlow = data.find(item => item.name === 'setTwoFlow')
          let threeFlow = data.find(item => item.name === 'setThreeFlow')
          let fourFlow = data.find(item => item.name === 'setFourFlow')
          let oneBig = data.find(item => item.name === 'setOneBig')
          let oneSmall = data.find(item => item.name === 'setOneSmall')
          let twoBig = data.find(item => item.name === 'setTwoBig')
          let twoSmall = data.find(item => item.name === 'setTwoSmall')
          let threeBig = data.find(item => item.name === 'setThreeBig')
          let threeSmall = data.find(item => item.name === 'setThreeSmall')
          let fourBig = data.find(item => item.name === 'setFourBig')
          let fourSmall = data.find(item => item.name === 'setFourSmall')
          let fiveBig = data.find(item => item.name === 'setFiveBig')
          let fiveSmall = data.find(item => item.name === 'setFiveSmall')
          if (oneFlow) {
            this.setColdDryer.setOneFlow = oneFlow.value
          }
          if (twoFlow) {
            this.setColdDryer.setTwoFlow = twoFlow.value
          }
          if (threeFlow) {
            this.setColdDryer.setThreeFlow = threeFlow.value
          }
          if (fourFlow) {
            this.setColdDryer.setFourFlow = fourFlow.value
          }
          if (oneBig) {
            this.setColdDryer.setOneBig = oneBig.value
          }
          if (oneSmall) {
            this.setColdDryer.setOneSmall = oneSmall.value
          }
          if (twoBig) {
            this.setColdDryer.setTwoBig = twoBig.value
          }
          if (twoSmall) {
            this.setColdDryer.setTwoSmall = twoSmall.value
          }
          if (threeBig) {
            this.setColdDryer.setThreeBig = threeBig.value
          }
          if (threeSmall) {
            this.setColdDryer.setThreeSmall = threeSmall.value
          }
          if (fourBig) {
            this.setColdDryer.setFourBig = fourBig.value
          }
          if (fourSmall) {
            this.setColdDryer.setFourSmall = fourSmall.value
          }
          if (fiveBig) {
            this.setColdDryer.setFiveBig = fiveBig.value
          }
          if (fiveSmall) {
            this.setColdDryer.setFiveSmall = fiveSmall.value
          }
        }
      },
      tellCleanProcess () {
        // 清理进程栏
        this.$refs.chain.feedMe({})
        // 重置 配置 栏
        this.makeSettingDefault()
      },
      makeSettingDefault () {
        this.operation1 = '未选择'
        this.operation2 = '设定参数'
        this.kitty = 999
        this.setSingleFreq.param = ''
      },
      pressRadioChange (index) {
        if (index === '1') {
          this.alertTitle = '自动控制'
        } else {
          this.alertTitle = '人工控制'
        }
        this.$Modal.confirm({
        title: '确认操作',
        content: '您确定切换到'+this.alertTitle+'吗?',
        onOk: () => {
          if (index === '1') {
            this.tellCleanProcess()
          }
          this.tipName3 = '切换模式：' + index
          this.changModelRequest(index, 162)
          this.pressSendStatus = true
        },
        okText: '确定',
        cancelText: '取消',
        onCancel: () => {
          if (index === '1') {
            this.models.modelPress = '0'
          } else {
            this.models.modelPress = '1'
          }
        }
      })
      },
      pressRadioChange2 (index) {
        if (index === '1') {
          this.alertTitle = '自动控制'
        } else {
          this.alertTitle = '人工控制'
        }
        this.$Modal.confirm({
          title: '确认操作',
          content: '您确定切换到'+this.alertTitle+'吗?',
          onOk: () => {
            if (index === '1') {
              this.tellCleanProcess()
            }
            this.tipName4 = '切换模式：' + index
            // 跟 162 一样
            this.changModelRequest(index, 163)
            this.press2SendStatus = true
          },
          okText: '确定',
          cancelText: '取消',
          onCancel: () => {
            if (index === '1') {
              this.models.modelCool = '0'
            } else {
              this.models.modelCool = '1'
            }
          }
        })

      },
      radioChangeBeng (index) {

        if (index === '1') {
          this.alertTitle = '自动控制'
        } else {
          this.alertTitle = '人工控制'
        }
        this.$Modal.confirm({
          title: '确认操作',
          content: '您确定切换到'+this.alertTitle+'吗?',
          onOk: () => {
            if (index === '1') {
              this.tellCleanProcess()
            }
            this.tipName = '切换模式：' + index
            this.changModelRequest(index, 160)
            this.bengModelSendStatus = true
          },
          okText: '确定',
          cancelText: '取消',
          onCancel: () => {
            if (index === '1') {
              this.models.modelBeng = '0'
            } else {
              this.models.modelBeng = '1'
            }
          }
        })

      },
      radioChangeTower (index) {

        if (index === '1') {
          this.alertTitle = '自动控制'
        } else {
          this.alertTitle = '人工控制'
        }
        this.$Modal.confirm({
          title: '确认操作',
          content: '您确定切换到'+this.alertTitle+'吗?',
          onOk: () => {
            if (index === '1') {
              this.tellCleanProcess()
            }
            this.tipName2 = '切换模式：' + index
            this.changModelRequest(index, 161)
            this.towerModelSendStatus = true
          },
          okText: '确定',
          cancelText: '取消',
          onCancel: () => {
            if (index === '1') {
              this.models.modelTower = '0'
            } else {
              this.models.modelTower = '1'
            }
          }
        })

      },
      sendSetKonYaPress () {
              if (!(this.setKongYaParam.setUp > this.setKongYaParam.setDown)) {
                this.$Message.info('操作有误，未能发送指令')
                return
              }
              this.setKongYaParam.sendingStatus = true
              window.myapi.do_post('iot/dev/updataDef', this.setKongYaParam).then(resp => {
                if (resp.status === 200) {
                  if (resp.data.data === 2) {
                    this.$Notice.success({
                      title: '操作反馈',
                      desc: '操作成功'
                    })
                  }
                  if (resp.data.data === 0) {
                    this.$Notice.success({
                      title: '操作反馈',
                      desc: '操作失败'
                    })
                  }
                }
              }).catch(error => {
              }).finally(() => {
                this.setKongYaParam.sendingStatus = false
              })
            },
            sendSetPress () {
              if (!(this.setPressParam.setUp > this.setPressParam.setDown)) {
                this.$Message.info('操作有误，未能发送指令')
                return
              }
              this.setPressParam.sendingStatus = true
              window.myapi.do_post('iot/dev/updataDef', this.setPressParam).then(resp => {
                if (resp.status === 200) {
                  if (resp.data.data === 2) {
                    this.$Notice.success({
                      title: '操作反馈',
                      desc: '操作成功'
                    })
                  }
                  if (resp.data.data === 0) {
                    this.$Notice.success({
                      title: '操作反馈',
                      desc: '操作失败'
                    })
                  }
                }
              }).catch(error => {
              }).finally(() => {
                this.setPressParam.sendingStatus = false
              })
            },
            sendSetColdDryer() {
              /*if (!(this.setTemeputureParam.setUp > this.setTemeputureParam.setDown)) {
                this.$Message.info('操作有误，未能发送指令')
                return
              }*/

              this.setColdDryer.sendingStatus = true
              // 发送写指令设备1
              window.myapi.do_post('iot/dev/updataDef', this.setColdDryer).then(resp => {
                if (resp.status === 200) {
                  if (resp.data.data === 14) {
                    this.$Notice.success({
                      title: '操作反馈',
                      desc: '操作成功'
                    })
                  }
                  if (resp.data.data === 0) {
                    this.$Notice.success({
                      title: '操作反馈',
                      desc: '操作失败'
                    })
                  }
                }
              }).catch(error => {
              }).finally(() => {
                this.setColdDryer.sendingStatus = false
              })
            },
            sendSetTempeture () {
              if (!(this.setTemeputureParam.setUp > this.setTemeputureParam.setDown)) {
                this.$Message.info('操作有误，未能发送指令')
                return
              }

              this.setTemeputureParam.sendingStatus = true
              // 发送写指令设备1
              window.myapi.do_post('iot/dev/updataDef', this.setTemeputureParam).then(resp => {
                if (resp.status === 200) {
                  if (resp.data.data === 2) {
                    this.$Notice.success({
                      title: '操作反馈',
                      desc: '操作成功'
                    })
                  }
                  if (resp.data.data === 0) {
                    this.$Notice.success({
                      title: '操作反馈',
                      desc: '操作失败'
                    })
                  }
                }
              }).catch(error => {
              }).finally(() => {
                this.setTemeputureParam.sendingStatus = false
              })
            },
      changModelRequest (model, devId) {
        let params = {cmd: model === '1' ? 'open' : 'close', devId: devId, param: ''}
        window.myapi.do_post('iot/dev/cmdById', params).then(resp => {
          if (resp.status === 200 && resp.data.status === 200) {
            if (resp.data.data === 1) {
              this.$Notice.success({
                title: '操作反馈',
                desc: '操作成功'
              })
            }
            if (resp.data.data === 2) {
              this.$Notice.success({
                title: '操作反馈',
                desc: '非远程状态无法控制'
              })
            }
          }
        }).catch(error => {
        }).finally(() => {
          this.bengModelSendStatus = false
          this.towerModelSendStatus = false
          this.pressSendStatus = false
          this.press2SendStatus = false
        })
      },
      sendSetFreq () {
        if (!this.dataObj.setFrequ) {
          this.$Message.info('操作有误，未能发送指令')
          return
        }
        this.setSingleFreq.sendingStatus = true
        let singleFreqCmd = { devId: this.setSingleFreq.devId, cmd: this.setSingleFreq.cmd, param: this.dataObj.setFrequ*10 }
        // 发送写指令设备1
        window.myapi.do_post('iot/dev/cmdById', singleFreqCmd).then(resp => {
          if (resp.status === 200 && resp.data.status === 200) {
            if (resp.data.data === 1) {
              this.$Notice.success({
                title: '操作反馈',
                desc: '操作成功'
              })
            }
            if (resp.data.data === 2) {
              this.$Notice.success({
                title: '操作反馈',
                desc: '非远程状态无法控制'
              })
            }
          }
        }).catch(error => {
        }).finally(() => {
          this.setSingleFreq.sendingStatus = false
        })
      }
    }
  }
</script>

<style scoped>
  .ddkkk{
    float: right;
    margin-right: 20px;
    color: gainsboro;
  }
  .ddkkkk{
    float: right;
  }
  .bgg {
    width: 100%;
    padding: 5px;
  }

  .tPart {
    width: 100%;
  }

  .bPart {
    width: 100%;
    border: solid #eceeee 1px;
    background: #fdfdff;
  }
  .fgap {
    width: 100%;
    height: 20px;
  }
  /*2k: 2560x1440*/
  @media screen and (min-width: 1921px) {
    .bgg {
      height: 1220px
    }
    .tPart {
      height: 1080px
    }
    .bPart {
      height: 120px
    }
  }

  /* 1080: 1920*1080 */
  @media screen and (max-width: 1920px)  and (min-width: 1601px) {
    .bgg {
      height: 960px;
    }

    .tPart {
      height: 830px
    }

    .bPart {
      height: 110px
    }
  }

  /* 1600: 1600*900  */
  @media screen and (max-width: 1600px) and (min-width: 1367px) {
    .bgg {
      height: 810px;
    }

    .tPart {
      height: 660px
    }

    .bPart {
      height: 120px
    }
  }

  /* 1366: 1366*678 */
  @media screen and (max-width: 1366px) {
    .bgg {
      height: 660px;
    }

    .tPart {
      height: 540px
    }

    .bPart {
      height: 100px
    }
  }

  .leftP {
    width: 65%;
    height: 100%;
    float: left;
  }

  .leftR {
    width: 35%;
    height: 100%;
    float: left;
    padding: 0px 0px 0px 20px;
  }
  .parts{
    width: 100%;
    height: 49%;
    border: #eceeee 1px solid;
    border-radius: 5px;
    background: #fdfdff;
    position: relative;
  }
  .gass {
    height: 2%;
    width: 100%;
  }

  .btnnn {
    padding: 10px 3px;
  }

  .leftBP {
    width: 65%;
    height: 100%;
    float: left;
  }
  .rightBP {
    width: 35%;
    height: 100%;
    float: left;
    padding-left: 20px;
  }
  .showNum{
    text-align: right;
    padding-right: 15px;
  }
  .bbleft{
    width: 30%;
    height: 100%;
    float: left;
    border-right: solid 1px #eceeee;
    border-left: solid 1px #eceeee;
    text-align: center;
    padding: 10px;
    background: #faf6f6;
  }
  .bbright{
    width: 70%;
    height: 100%;
    float: left;
  }

  .demo-spin-icon-load {
    animation: ani-demo-spin 1s linear infinite;
  }
</style>
